<?php
    class Cataloge_Model extends dl_connect{
        
        function __construct(){
            $this->Connect();
        }
        
        /**
         * insert a record to street table
         * @return INT
         * */
        public function add($catId, $name){
            $this->ExecuteSQL("INSERT INTO `dulich`.`cataloge` (`cat_id` , `cat_name`)
                                VALUES ('{$catId}', '{$name}')");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
        
        /**
         * edit a record from street table
         * @return INT
         * */
        public function edit($catId, $name){
            $this->ExecuteSQL("UPDATE `dulich`.`cataloge` SET `cat_name` = '{$name}' WHERE `cataloge`.`cat_id` = '{$catId}'");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
        
        /**
         * delete a record from street table
         * @return INT
         * */
        public function delete($id){
            $this->ExecuteSQL("DELETE FROM `dulich`.`cataloge` WHERE `cataloge`.`cat_id` = \'{$id}\'");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
         
    }
?>